﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");

		response = structNew();
		structInsert(response, "success", false, true);

		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		clsroomId = event.getArg("crid");
		
		transaction {
			
			/* 载入教学任务 */
			sql = "SELECT 1 FROM t_new_examtask where task_id = :taskId ";
			
			queryObj = new Query(datasource=application.dnsMaster);
			
			queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
			
			rs_task = queryObj.execute( sql=sql ).getResult();
			
			/* 修改期末考试教室类别 */
			switch(taskType){
				case 'P':
					if( rs_task.recordCount ){
						sql = "UPDATE t_new_examtask a 
							SET a.cr_id = :clsroomId,
								a.is_arranged = '1'  
							WHERE a.task_id = :taskId ";
					}else{
						sql = "INSERT INTO t_new_examtask(task_id,cr_id,is_arranged)values(
								:taskId, :clsroomId,'1'
						) ";	
					}
					
					break;
				/*case 'C':
					sql = "UPDATE t_common_task a 
							SET a.cr_type = :clsroomType 
							WHERE a.tsk_id = :taskId ";
					break;
				case 'R':
					sql = "UPDATE t_reopen_task a 
							SET a.cr_type = :clsroomType  
							WHERE a.tsk_id = :taskId ";
					break;
				case 'T':
					sql = "UPDATE t_sport_task a 
							SET a.cr_type = :clsroomType 
							WHERE a.tsk_id = :taskId ";
					break;*/
			}
			
			updateObj = new Query(datasource=application.dnsMaster);
			updateObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
			updateObj.addParam(name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char");
			updateObj.execute(sql=sql);
			
			structInsert(response, "success", true, true);
			
		}
		
		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>